//
//  HNCreditGoldController.m
//  XDEducation
//
//  Created by 星道 on 17/5/31.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "HNCreditGoldController.h"
#import "HNCreditGoldTargetDetailTableView.h"

@interface HNCreditGoldController ()
{
    //头部视图
    IBOutlet UIImageView *_img;
    IBOutlet UILabel *_love;
    IBOutlet UILabel *_glory;
    IBOutlet UILabel *_efforts;
    IBOutlet UILabel *_contract;
    
    //底部视图
    //小目标
    IBOutlet UILabel *_small_completed;
    IBOutlet UILabel *_small_complete;
    //大目标
    IBOutlet UILabel *_big_completed;
    IBOutlet UILabel *_big_complete;
    
}
@end

@implementation HNCreditGoldController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title = @"我的约定";
    
    [_img sd_setImageWithURL:[NSURL URLWithString:BaseIconUrl(self.Image)] placeholderImage:[UIImage imageNamed:@"image_user_default"]];
    _love.text = [NSString stringWithFormat:@"LV%ld",[self GetLevelWithIndex:[self.Love integerValue]]];
    _glory.text = [NSString stringWithFormat:@"LV%ld",[self GetLevelWithIndex:[self.Glory integerValue]]];
    _efforts.text = [NSString stringWithFormat:@"LV%ld",[self GetLevelWithIndex:[self.Efforts integerValue]]];
    _contract.text = [NSString stringWithFormat:@"LV%ld",[self GetLevelWithIndex:[self.Contract integerValue]]];
    
    _small_complete.text = [self.Small_NoFinish stringValue];
    _small_completed.text = [self.Small_Finish stringValue];
    
    _big_complete.text = [self.Big_NoFinish stringValue];
    _big_completed.text = [self.Big_Finish stringValue];
}




//转换等级
- (NSInteger)GetLevelWithIndex:(NSInteger)Index
{
    if (Index <= 20) {
        return  1;
    } else if (Index <= 50) {
        return 2;
    } else if (Index <= 100) {
        return 3;
    } else if (Index <= 500) {
        return 4;
    } else if (Index <= 1000) {
        return 5;
    } else if (Index <= 2000) {
        return 6;
    } else if (Index <= 5000) {
        return 7;
    } else if (Index <= 10000) {
        return 8;
    } else {
        return 9;
    }
}





#pragma mark - Action
- (IBAction)GoDetail:(id)sender
{
    NSInteger tag = [(UIButton *)sender tag];
    HNCreditGoldTargetDetailTableView *TVC = [[HNCreditGoldTargetDetailTableView alloc] init];
    TVC.HNCreditGoldTargetDetailAccoutType = (NSInteger)self.HNCreditGoldControllerAccoutType;
    TVC.executeUid = self.uid;
    TVC.HNCreditGoldTargetDetailType = (tag-1100);
    TVC.ChildID = [self.executeUid stringValue];
    [self.navigationController pushViewController:TVC animated:YES];
}

- (NSString *)Image
{
    if (!_Image)
    {
        _Image = @"";
    }
    return _Image;
}
@end
